package dongshi.daddy.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

//public class MyIterator implements Iterator<String> {
public class MyIterator implements Iterable<String> {
    private List<String> items = new ArrayList() {
        {
            add("aaa");
            add("bbb");
        }
    };
    private static int num = 0;
    /*@Override
    public boolean hasNext() {
        return num < items.size();
    }

    @Override
    public String next() {
        return items.get(num++);
    }*/

    @Override
    public Iterator<String> iterator() {
        return new Iterator<String>() {
            @Override
            public boolean hasNext() {
                return num < items.size();
            }

            @Override
            public String next() {
                return items.get(num++);
            }
        };
    }
}
